/**
 * 
 */
$(document).ready(function(){
	var windowHeight = $(document).height();
	$("#treeMenu").css("min-height",windowHeight-40);
	var menuResult='';
	var menuListUrl = adminQueryUrl +menuService+"/queryLeftMenu.action";
//	var param="action=queryLeftMenuList";
	var token = $.zui.store.get("token");
	var userId = $.zui.store.get("userId");
	var headpic = $.zui.store.get("headpic");


	//var pic='<img src="'+abcolutepath+'" width="40px" height="40px" class="img-circle" >';
	var pic='<img src="http://zui.sexy/docs/img/img2.jpg"  width="40px" height="40px" class="img-circle"  >';
	//<img src="'+contextPath+'/'+data[i].apicpath+'" width="1200px" height="380px">
	 $("#headpic").html(pic); 

	//<img src="http://zui.sexy/docs/img/img2.jpg" width="200px" height="200px" class="img-circle" alt="圆形图片">
	console.log('token='+token+",userId="+userId);
	var param="";
	/*
	$.get(menuListUrl,function(data,status){
		console.log('data='+data);
		var result= data.menuList;
	  console.log('result='+result);  
		if(data.success=="1"){
			alert(data.success);
			var myTree = $('#treeMenu').data('zui.tree');	
			for(var i=0;i<result.length;i++){   	
				if(result[i].menuParentCode=="#"){
					menuResult += '<li>';
					menuResult += '<a href="#" ><i class="icon icon-list"></i>';
					menuResult +=result[i].menuName+'</a>';
					for(var j=0;j<result.length;j++){
						
						 if(result[i].menuCode==result[j].menuParentCode){
							
							 menuResult += '<ul>';	
			        		  menuResult += '<li><a href="javascript:;"  style="color:blue;"  onclick="'+result[j].menuUrl+'" >';
			        		  menuResult += '<i class="icon icon-circle-blank"></i>'+result[j].menuName+'</a></li>';
			        		  menuResult += '</ul>';
			        	
						 }
					 }
					 menuResult += '</li>'; 
				}
					
				 $("#treeMenu").html(menuResult); 
			}
		}
		
	},"json");*/
	/*$.ajax({
		url:menuListUrl,
		type:'post',
	//	data:param,
		dataType:"JSON",
		beforeSend:function(xhr){
			xhr.setRequestHeader("token",token);
			xhr.setRequestHeader("userId",userId);
		},
		header:{"token":token,"userId":userId},
		success:function(data){
			var result=data.menuList;
			console.log("result="+result);
			var myTree = $('#treeMenu').data('zui.tree');
			for(var i=0;i<result.length;i++){   	
				if(result[i].menuParentCode=="#"){
					menuResult += '<li>';
					menuResult += '<a href="#" ><i class="icon icon-list"></i>';
					menuResult +=result[i].menuName+'</a>';
					for(var j=0;j<result.length;j++){
						
						 if(result[i].menuCode==result[j].menuParentCode){
							
							 menuResult += '<ul>';	
			        		  menuResult += '<li><a href="javascript:;"  style="color:blue;"  onclick="'+result[j].menuUrl+'" >';
			        		  menuResult += '<i class="icon icon-circle-blank"></i>'+result[j].menuName+'</a></li>';
			        		  menuResult += '</ul>';
			        	
						 }
					 }
					 menuResult += '</li>'; 
				}
					
				 $("#treeMenu").html(menuResult); 
			}
            
		}

	});*/
	
	$.ajax({
		url:menuListUrl,
		type:'post',
		beforeSend:function(xhr){
			xhr.setRequestHeader("token",token);
			xhr.setRequestHeader("userId",userId);
		},
		dataType:"JSON",
		data:param,
		success:function(data){
			console.log(data);
			if(data.success=="1"){
			var result=new Array();
				 result=data.menuList;
				 console.log(result);
				var myTree = $('#treeMenu').data('zui.tree');
				for(var i=0;i<result.length;i++){  
					
					if(result[i].MENU_PARENT_CODE=="#"){
						menuResult += '<li>';
						//javascript:;"  style="color:blue;"  onclick="'+result[i].MENU_URL+'
						menuResult += '<a href="#" ><i class="icon icon-list"></i>';
						menuResult +=result[i].MENU_NAME+'</a>';
						for(var j=0;j<result.length;j++){
							
							 if(result[i].MENU_CODE==result[j].MENU_PARENT_CODE){
								
								 menuResult += '<ul>';	
				        		  menuResult += '<li><a href="javascript:;"  style="color:blue;"  onclick="'+result[j].MENU_URL+'" >';
				        		  menuResult += '<i class="icon icon-circle-blank"></i>'+result[j].MENU_NAME+'</a></li>';
				        		  menuResult += '</ul>';
				        	
							 }
						 }
						 menuResult += '</li>'; 
					}
						
					 $("#treeMenu").html(menuResult); 
				}
			}
		}
		
	});	
	
});


function loginout(){
	if(confirm("您确定要退出登录吗?")){
		$.zui.store.clear();
		location.href='../login.jsp';
	}
}

function reloadMainRight(name){
	$("#adminRight2").empty();
	$("#adminRight2").load(name);
}

